using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_ITEMMap : EntityTypeConfiguration<SO_ITEM>
    {
        public SO_ITEMMap()
        {
            // Primary Key
            this.HasKey(t => new { t.DESCRIPTION, t.TYPE, t.COST, t.STATUS, t.Flat_price });

            // Properties
            this.Property(t => t.ITEM)
                .HasMaxLength(10);

            this.Property(t => t.DESCRIPTION)
                .IsRequired()
                .HasMaxLength(250);

            this.Property(t => t.code)
                .HasMaxLength(20);

            this.Property(t => t.BARCODE)
                .HasMaxLength(20);

            this.Property(t => t.TYPE)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.CATEGORY)
                .HasMaxLength(30);

            this.Property(t => t.VENDOR)
                .HasMaxLength(50);

            this.Property(t => t.VENDOR_id)
                .HasMaxLength(6);

            this.Property(t => t.UNIT_OF_ORDER)
                .HasMaxLength(50);

            this.Property(t => t.UNIT_OF_SALES)
                .HasMaxLength(50);

            this.Property(t => t.STATUS)
                .IsRequired()
                .HasMaxLength(8);

            // Table & Column Mappings
            this.ToTable("SO_ITEM");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.DESCRIPTION).HasColumnName("DESCRIPTION");
            this.Property(t => t.code).HasColumnName("code");
            this.Property(t => t.BARCODE).HasColumnName("BARCODE");
            this.Property(t => t.TYPE).HasColumnName("TYPE");
            this.Property(t => t.CATEGORY).HasColumnName("CATEGORY");
            this.Property(t => t.VENDOR).HasColumnName("VENDOR");
            this.Property(t => t.VENDOR_id).HasColumnName("VENDOR_id");
            this.Property(t => t.UNIT_OF_ORDER).HasColumnName("UNIT_OF_ORDER");
            this.Property(t => t.UNIT_OF_SALES).HasColumnName("UNIT_OF_SALES");
            this.Property(t => t.FACTOR).HasColumnName("FACTOR");
            this.Property(t => t.COST).HasColumnName("COST");
            this.Property(t => t.UNIT_COST).HasColumnName("UNIT_COST");
            this.Property(t => t.STATUS).HasColumnName("STATUS");
            this.Property(t => t.Flat_price).HasColumnName("Flat_price");
            this.Property(t => t.VAT_ENABLED).HasColumnName("VAT_ENABLED");
        }
    }
}
